import React from 'react';
import { Table, Icon } from 'antd';
import timeFormat from 'utils/time';

export default function ConditionTable({ dataSource }) {
  const columns = [
    {
      title: '状态名称',
      dataIndex: 'type',
      key: 'type',
      width: 'auto',
    },
    {
      title: '上次更新时间',
      dataIndex: 'lastUpdateTime',
      key: 'lastUpdateTime',
      render: timeFormat,
      width: 'auto',
    },
    {
      title: '相关信息',
      dataIndex: 'message',
      key: 'message',
      textWrap: 'word-break',
      width: 'auto',
    },
    {
      title: '状态值',
      dataIndex: 'status',
      key: 'status',
      render: (status) => {
        if (status === 'True') {
          return <Icon type="check" />;
        }
        if (status === 'False') {
          return <Icon type="close" />;
        }
        return <Icon type="question" />;
      },
    },
  ];
  return <Table rowKey="type" dataSource={dataSource} columns={columns} />;
}
